//
//  UIBarButtonItem+extension.swift
//  weiboDemo
//
//  Created by zq on 2020/10/28.
//

import UIKit

extension UIBarButtonItem{
    
    /// 便利构造函数,convenience:便利
    /// - Parameters:
    ///   - title: 名称
    ///   - fontSize: 默认16号字体
    ///   - target:
    ///   - action:
    convenience init(title:String,fontSize:CGFloat = 16,target:Any?,action: Selector,isBack:Bool = false){
        let btn:UIButton = UIButton.cz_textButton(title, fontSize: 16, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        if isBack {
            btn.setImage(UIImage(named: "navigationbar_back_withtext"), for: .normal)
            btn.setImage(UIImage(named: "navigationbar_back_withtext_highlighted"), for: .highlighted)
            btn.sizeToFit()
        }
        btn.addTarget(target, action: action, for: .touchUpInside)
        self.init(customView:btn)
    }
}
